<template>
  <div style="float: left;" >
    <a
        href="javascript:;"
        @click="handleLogout"
        class="ant-pro-global-header-index-action1" >
      <a-icon type="logout"/>
      退出
    </a>
  </div>
</template>

<script>
import { mapActions } from 'vuex'

export default {
  name: 'LoginOut',
  components: {
  },
  computed: {
  },
  methods: {
    ...mapActions(['Login', 'Logout']),
    handleLogout () {
      this.$confirm({
        title: '提示',
        content: '真的要注销登录吗 ?',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          return this.Logout({}).then(() => {
            setTimeout(() => {
              window.location.reload()
            }, 16)
          }).catch(err => {
            this.$message.error({
              title: '错误',
              description: err.message
            })
          })
        },
        onCancel () {
        }
      })
    }
  }
}
</script>
